package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.hjq.shape.view.ShapeTextView;
import com.hjq.widget.layout.WrapRecyclerView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.GetStudentPlanDetailApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class StudentPlan2Adapter extends AppAdapter<GetStudentPlanDetailApi.Bean.ListDTO.ListDTO2> {

    public StudentPlan2Adapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvTime;
        private ShapeTextView mTvStatus;
        private ShapeTextView mTvTeacherName;
        private ShapeTextView mTvGetClassNum;
        private ShapeTextView mTvBtn;
        private ShapeTextView mTvType;








        private ViewHolder() {
            super(R.layout.item_student_plan2);
            mTvTime = findViewById(R.id.tv_time);
            mTvStatus = findViewById(R.id.tv_status);
            mTvType = findViewById(R.id.tv_type);
            mTvTeacherName = findViewById(R.id.tv_teacher_name);
            mTvGetClassNum = findViewById(R.id.tv_get_class_num);
            mTvBtn = findViewById(R.id.tv_btn);
        }

        @Override
        public void onBindView(int position) {
            GetStudentPlanDetailApi.Bean.ListDTO.ListDTO2 bean = getItem(position);
            mTvTime.setText(bean.getTime());
            //1理论 2实操
            if (bean.getClass_type()==1){
                mTvType.setText("理论");
                mTvType.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_E3F6EC))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_18B566))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvType.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_18B566))
                        .intoTextColor();
            }else if (bean.getClass_type()==2){
                mTvType.setText("实操");
                mTvType.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_FFF2E7))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_FF8018))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvType.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_FF8018))
                        .intoTextColor();
            }
            if (bean.getLecture_type()==1){
                mTvStatus.setText("线上直播");
            }else{
                mTvStatus.setText("线下打卡");
            }
            mTvTeacherName.setText(bean.getTeacher_name());
            mTvGetClassNum.setText(bean.getGet_class_num()+"");
            //0未开始 1去打卡/观看直播 2去补卡/观看回放  4已打卡
            if (bean.getStatus()==0){
                mTvBtn.setText("未开始");
                mTvBtn.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_F7F8F8))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_F7F8F8))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvBtn.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_7F7F7F))
                        .intoTextColor();
            }else if (bean.getStatus()==1){
                mTvBtn.setText("去打卡");
                mTvBtn.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_EAF1FE))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_3675FE))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvBtn.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_3675FE))
                        .intoTextColor();
            }else if (bean.getStatus()==2){
                mTvBtn.setText("去补卡");
                mTvBtn.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_FFF2E7))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_FF8018))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvBtn.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_FF8018))
                        .intoTextColor();
            }else if (bean.getStatus()==4){
                mTvBtn.setText("已打卡");
                mTvBtn.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_FFF2E7))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_FF8018))
                        .setStrokeWidth(1)
                        .intoBackground();
                mTvBtn.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_FF8018))
                        .intoTextColor();
            }
        }
    }
}